package com.bdqn.vueboot.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bdqn.vueboot.entity.ConferenceRoot;
import com.bdqn.vueboot.entity.Furniture;
import com.bdqn.vueboot.service.ConferenceRootService;
import com.bdqn.vueboot.mapper.ConferenceRootMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

/**
 *
 */
@Service
public class ConferenceRootServiceImpl extends ServiceImpl<ConferenceRootMapper, ConferenceRoot>
        implements ConferenceRootService {
    @Resource
    ConferenceRootMapper conferenceRootMapper;

    @Override
    public IPage<ConferenceRoot> findAllByConferenceListBiz(String conferenceTitle, String conferencename, Integer meetingStatusId,Integer indexPage, Integer limit) {
        Page<ConferenceRoot> page = new Page<>(indexPage, limit);
        return conferenceRootMapper.findAllByConferenceList(conferenceTitle, conferencename,meetingStatusId, page);
    }

    @Override
    public int addConferenceRoot(ConferenceRoot conferenceRoot) {
        if (conferenceRoot.getOdd() == null || conferenceRoot.getOdd() == 0) {
            conferenceRoot.setTimeApplication(LocalDateTime.now());
            conferenceRoot.setIsDele(0);
            return conferenceRootMapper.insert(conferenceRoot);
        } else {
            conferenceRoot.setTimeApplication(LocalDateTime.now());
            return conferenceRootMapper.updateById(conferenceRoot);
        }
    }

    @Override
    public int delIsDeleByOdd(Long odd, Long isDele) {
        return conferenceRootMapper.delIsDeleByOdd(odd, isDele);
    }

    @Override
    public int sevaAudit(Integer meetingStatusId, Long odd) {
        UpdateWrapper<ConferenceRoot> updateWrapper = new UpdateWrapper();
        updateWrapper.eq("odd", odd);
        ConferenceRoot conferenceRoot = new ConferenceRoot();
        conferenceRoot.setMeetingStatusId(meetingStatusId);
        return conferenceRootMapper.update(conferenceRoot, updateWrapper);
    }
}




